#include <iostream>
using namespace std;

class A {
  public:
    A();
    virtual ~A();
    virtual void f() const;
};

class B : public A {
  public:
    B();
    ~B() override;
    void f() const override;
};

A::A() { cout << "A()" << endl; }
A::~A() { cout << "~A()" << endl; }
void A::f() const { cout << "A::f()" << endl; }

B::B() { cout << "B()" << endl; }
B::~B() { cout << "~B()" << endl; }
void B::f() const { cout << "B::f()" << endl; }

int main() {
    B obj;
    A *p = &obj;
    p->f();

    return 0;
}
